//
//  MBBaseNaviView.m
//  MemberBusiness-ios
//
//  Created by cherry pu on 2018/4/23.
//  Copyright © 2018年 zhangXin. All rights reserved.
//

#import "MBBaseNaviView.h"


@implementation MBBaseNaviView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        CAGradientLayer *gradientLayer0 = [[CAGradientLayer alloc] init];
        gradientLayer0.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_STATUS_BAR_HEIGHT+44);
        gradientLayer0.colors = @[
                                  (id)[UIColor colorWithRed:255.0f/255.0f green:136.0f/255.0f blue:0.0f/255.0f alpha:1.0f].CGColor,
                                  (id)[UIColor colorWithRed:255.0f/255.0f green:99.0f/255.0f blue:0.0f/255.0f alpha:1.0f].CGColor];
        gradientLayer0.locations = @[@0, @1];
        [gradientLayer0 setStartPoint:CGPointMake(0, 0)];
        [gradientLayer0 setEndPoint:CGPointMake(1, 0)];
        [self.layer addSublayer:gradientLayer0];

        UILabel* titleLabel = [[UILabel alloc]init];
        self.titleLabel = titleLabel;
        titleLabel.font = [UIFont lf_regularFontOfSize:18];
        titleLabel.textColor = [UIColor whiteColor];
        [self addSubview:titleLabel];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(self).offset(SCREEN_STATUS_BAR_HEIGHT+14);
        }];

    }
    return self;
}

-(void)setUpBackButton
{
    UIButton* backButton = [[UIButton alloc]init];
    [backButton setImage:[UIImage imageNamed:@"nav_2_1_back"] forState:UIControlStateNormal];
    self.backButton = backButton;
    [self addSubview:backButton];
    
    [backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.titleLabel);
        make.left.equalTo(self).offset([UIView lf_sizeFromIphone6:13]);
    }];

}

@end
